# _*_ coding utf-8 _*_
# FILENAME：versionListUI.py
# DESCRIPTION: 版本管理界面
# AUTH: jarvis zhang
# DATE: 2022/5/31 10:53 上午


from PyQt5 import QtCore, QtGui
from PyQt5.QtWidgets import *
from PyQt5.Qt import *
import qtawesome as qta


class VersionListUI(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowTitle("版本管理")
        MainWindow.resize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")

        grid = QGridLayout()  # 网格布局

        # toolbar
        self.toolBar = QToolBar(MainWindow)
        self.toolBar.setObjectName("toolbar")
        self.toolBar.setFixedHeight(32)
        # self.btn_upload = QPushButton('上传')
        # self.btn_upload.setIcon(qta.icon('mdi.file-upload-outline'))  # 设置图标
        self.btn_add = QPushButton('新增')
        self.btn_add.setIcon(qta.icon('ri.file-add-line'))  # 设置图标
        # self.btn_edit = QPushButton('编辑')
        # self.btn_edit.setIcon(qta.icon('mdi.circle-edit-outline'))  # 设置图标
        # self.btn_del = QPushButton('删除')
        # self.btn_del.setIcon(qta.icon('mdi.delete-empty-outline'))  # 设置图标
        self.btn_close = QPushButton('关闭')
        self.btn_close.setIcon(qta.icon('mdi.exit-run'))  # 设置图标
        # self.toolBar.addWidget(self.btn_upload)
        self.toolBar.addWidget(self.btn_add)
        # self.toolBar.addWidget(self.btn_edit)
        # self.toolBar.addWidget(self.btn_del)
        self.toolBar.addWidget(self.btn_close)
        MainWindow.addToolBar(Qt.TopToolBarArea, self.toolBar)

        '''数据列表设置'''
        self.data_table = QTableWidget()
        COLUMN = 5
        ROW = 0
        self.data_table.setColumnCount(COLUMN)
        self.data_table.setRowCount(ROW)
        h_table_header = ['序号', 'versionId', '版本名称', '创建时间', '操作']
        self.data_table.setHorizontalHeaderLabels(h_table_header)
        self.data_table.verticalHeader().setVisible(False)
        self.data_table.setShowGrid(True)
        self.data_table.setEditTriggers(QTableWidget.NoEditTriggers)
        self.data_table.setSelectionBehavior(QTableWidget.SelectRows)
        self.data_table.setSelectionMode(QTableWidget.SingleSelection)
        # 设置指定列的列宽
        self.data_table.setColumnWidth(0, 50)
        self.data_table.setColumnWidth(1, 100)
        self.data_table.setColumnWidth(2, 300)
        self.data_table.setColumnWidth(3, 200)
        self.data_table.setColumnWidth(4, 120)
        #隐藏列
        self.data_table.hideColumn(1)

        for index in range(self.data_table.columnCount()):
            headItem = self.data_table.horizontalHeaderItem(index)
            headItem.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        '''加入布局'''
        grid.addWidget(self.data_table, 0, 0, 1, 10)

        self.centralwidget.setLayout(grid)
        MainWindow.setCentralWidget(self.centralwidget)

        # statusbar
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)



